# $Id: PKGBUILD 181126 2013-03-31 19:16:54Z stephane $
# Maintainer: Ronald van Haren <ronald.archlinux.org>
# Contributor: Jason Chu <jason@archlinux.org>

pkgname=lyx
pkgver=2.0.5.1
pkgrel=3
pkgdesc="An advanced WYSIWYM document processor & LaTeX front-end"
arch=('i686' 'x86_64')
url="http://www.lyx.org"
depends=('qt4' 'texlive-core' 'python2' 'imagemagick' 'enchant' 'boost-libs' 'libmythes')
makedepends=('boost')
optdepends=('rcs: built-in version control system'
            'texlive-latexextra: float wrap support')
license=('GPL')
backup=('etc/lyx/lyxrc.dist')
install=lyx.install
options=('emptydirs')
source=(ftp://ftp.lip6.fr/pub/lyx/stable/2.0.x/$pkgname-$pkgver.tar.xz
        lyx.desktop lyxrc.dist)
sha1sums=('a822e99484c1652c4df5df717819dd7048fcff75'
          'e2b8f6d6cdeec41e1d5795167f5557e4a6ea28ad'
          '56416642cc3da2a13b87b84e6b87c1a239f3d09a')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  find . -type f -exec sed -i 's|#!.*python|#!/usr/bin/env python2|' {} +
  sed -i 's|"python|"python2|' lib/configure.py src/support/os.cpp
  export CXXFLAGS="$CXXFLAGS -fpermissive"
  ./configure --prefix=/usr \
    --with-frontend=qt4 --without-included-boost \
    --without-included-mythes
  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  make DESTDIR="${pkgdir}" install

  # install desktop entry
  install -Dm644 "${srcdir}/lyx.desktop" \
    "${pkgdir}/usr/share/applications/lyx.desktop"
  install -Dm644 "lib/images/lyx.png" \
    "${pkgdir}/usr/share/pixmaps/lyx.png"

  # install default config file
  install -Dm644 "${srcdir}/lyxrc.dist" "${pkgdir}/etc/lyx/lyxrc.dist"
  ln -sf /etc/lyx/lyxrc.dist "${pkgdir}/usr/share/lyx/lyxrc.dist"
}
